﻿using System;

class NextDate
{
    static void Main()
    {
        //Telerik Academy Exam 1 @ 27 Dec 2012

        int day = int.Parse(Console.ReadLine());
        int month = int.Parse(Console.ReadLine());
        int year = int.Parse(Console.ReadLine());
        int nextDay = 0;
        
        int lastdayMonth = 0;
        int remainderYear = year % 100;        

        switch (month)
        {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                lastdayMonth = 31;
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                lastdayMonth = 30;
                break;
            case 2:
                if (remainderYear % 4 == 0)
                {
                    lastdayMonth = 29;
                }
                else
                {
                    lastdayMonth = 28;
                }
                break;
            default:
                Console.WriteLine("wrong input");
                break;
        }

        if (day == lastdayMonth)
        {
            nextDay = 1;            
            if (month < 12)
	        {
                month += 1;		 
	        }
            else if (month == 12)
	        {
                month = 1;
                year += 1;
	        }            
        }
        else
        {
            nextDay = day + 1;
        }

        Console.WriteLine("{0}.{1}.{2}", nextDay, month, year);
        
    }
}

